<template>
  <div class='wrap' ref='wrap'>
    <div class="wrapson">
      <div class="star">
        <div class="star-left">
          <h3>4.2</h3>
          <p>综合评分</p>
          <p>高于周边商家69.2%</p>
        </div>
        <div class="star-right">
          <span>服务态度</span>&nbsp;<span class='star-on'></span><span class='star-on'></span><span class='star-on'></span><span
            class='star-on'></span><span class='star-off'></span> <span class='pingfen'>4.1</span><br>
          <span>商品评分</span>&nbsp;<span class='star-on'></span><span class='star-on'></span><span class='star-on'></span><span
            class='star-on'></span><span class='star-off'></span> <span class='pingfen'>4.3</span> <br>
          <span>送达时间</span>&nbsp;<i>38分钟</i>
        </div>
      </div>
      <div class="ratings">
        <div class="top">
          <span>全部</span>
          <span>满意</span>
          <span>不满意</span>
        </div>
        <div class="button">
          <i class='iconfont icon-check_circle'></i><span>只看有内容的评价</span>
        </div>
        <div class="count">
          <ul>
            <li v-for='item in list' ref='list'>
              <div class="pic">
                <img :src="item.avatar" alt="">
              </div>
              <div class="txt-right">
                <p>{{item.username}}</p>
                <span class='count-star-on'></span>
                <span class='count-star-on'></span>
                <span class='count-star-on'></span>
                <span class='count-star-on'></span>
                <span class='count-star-on'></span>
                <p>{{item.text}}</p>
                <div class="up">
                  <span class='iconfont icon-thumb_up'></span>
                  <span>南瓜粥</span><span>南瓜粥</span><span>南瓜粥</span><span>南瓜粥</span><span>南瓜粥</span>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import BetScroll from 'better-scroll'
  export default {
    data() {
      return {
        list: {},

      }
    },

    created() {

      this.$http.get('http://localhost:8080/api/getRatings')
        .then(function (resous) {
          if (resous.body.status !== 0) {
            // console.log(resous.body)
            this.list = resous.body.data;
            this.$nextTick(() => { // 3 在这个函数中调用以防内容还未加载完就执行，获取不到元素的高度导致无法滑动
              //console.log(this)   //可以打印看看this的内容
              this.warpHeight()


              this.ratingsScroll = new BetScroll(this.$refs.wrap, {})

            })
          }
        })

    },
    methods: {
      // 计算高度滚动父元素的高度
      warpHeight() {
        let hei = screen.height - 205
        this.$refs.wrap.style.height = hei + 'px'
        this.$refs.wrap.style.height = hei + 'px'
      },
      _initScroll() { // 2 函数声明

        this.ratingsScroll = new BetScroll(this.$refs.wrap, {})
      }
    }
  }

</script>
<style scoped>
  .wrap {
    background: #f3f5f7;
    overflow: hidden;
   
  }
  
  .star {
    padding: 20px 0;
    background: #fff;
    border-bottom: 1px solid #ccc;
  }
  
  .star .star-left {
    width: 150px;
    height: 85px;
    background: #fff;
    float: left;
    text-align: center;
    box-sizing: border-box;
    border-right: 1px solid #ccc;
  }
  
  .star .star-left h3 {
    font-size: 26px;
    color: orange;
  }
  
  .star .star-left p:last-child {
    color: #93999f;
    font-size: 10px;
  }
  
  .star .star-right {
    line-height: 30px;
    padding-left: 20px;
    box-sizing: border-box;
    background: #fff;
  }
  
  .star .star-right .star-on {
    vertical-align: middle;
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url(../images/xx.png) no-repeat;
    background-size: 15px 15px;
  }
  
  .star .star-right .pingfen {
    color: orange;
  }
  
  .star .star-right i {
    color: #93999f;
  }
  
  .star .star-right .star-off {
    vertical-align: middle;
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url(../images/x.png) no-repeat;
    background-size: 15px 15px;
  }
  
  .star .star-right {
    height: 85px;
    overflow: hidden;
  }
  
  .ratings {
    background: #fff;
    margin-top: 20px;
  }
  
  .ratings .top {
    padding: 20px;
  }
  
  .ratings .top span {
    margin-right: 5px;
    display: inline-block;
    width: 50px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    color: #4d555d;
    background: rgba(0, 160, 220, 0.2);
  }
  
  .ratings .button {
    padding-left: 20px;
    height: 40px;
    border-bottom: 1px solid #ccc;
  }
  
  .ratings .button i {
    float: left;
    color: #00c850;
    font-size: 22px;
  }
  
  .ratings .button span {
    float: left;
    line-height: 22px;
    color: #93999f;
  }
  
  .ratings .count .pic {
    box-sizing: border-box;
    padding: 10px;
    width: 50px;
    height: 100px;
    float: left;
  }
  
  .ratings .count .pic img {
    width: 28px;
    border-radius: 50%;
  }
  
  .ratings .count .txt-right {
    height: 100px;
    overflow: hidden;
  }
  
  .ratings .count .count-star-on {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: url(../images/xx.png) no-repeat;
    background-size: 10px 10px;
  }
  
  .ratings .count .count-star-off {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: url(../images/x.png) no-repeat;
    background-size: 10px 10px;
  }
  
  .ratings .count {
    line-height: 5px;
    /*height: 2400px;*/
  }
  
  .ratings .count .up span:nth-child(-n+6) {
    margin-right: 5px;
    display: inline-block;
    padding: 7px;
    border: 1px solid #ccc;
    color: #93999f;
  }
  
  .ratings .count .up span:first-child {
    color: #00a0dc;
    border: none;
  }
  
  .ratings .count .up span {
    font-size: 10px;
  }

</style>
